#include "stdafx.h"
#include "TNavigate.h"

#include "MainFrm.h"
#include "ChildFrm.h"
#include "TNavigateDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx)

BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx)
	ON_WM_MDIACTIVATE()
END_MESSAGE_MAP()

CChildFrame::CChildFrame(){}

CChildFrame::~CChildFrame() { }


BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIChildWndEx::PreCreateWindow(cs) )
		return FALSE;
	return TRUE;
}

#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
	CMDIChildWndEx::AssertValid();
}

void CChildFrame::Dump(CDumpContext& dc) const
{
	CMDIChildWndEx::Dump(dc);
}
#endif //_DEBUG

void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
	CMDIChildWndEx::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);

	CTNavigateDoc *pDoc = (CTNavigateDoc *)GetActiveDocument();
	if (!pDoc)
		return;

	TDbDataBase *pDb = &pDoc->GetDataBase();
	if (!pDb)
		return;

	TGlobalFunc::SetActiveDB(pDb);
	((CMainFrame*)AfxGetMainWnd())->GetEntTypeComboBox()->RefreshList();
	((CMainFrame*)AfxGetMainWnd())->GetEntFlorComboBox()->RefreshList();
}
